package DataBase;


import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 * This is the Class that opens connection to the DB .
 * @author Andrey
 * @author Igor
 */
public class SQLConnection 
{
	private Connection connection;
	private static String password = "Braude"; 
	private static String username = "root";
	
	
	/**
	 * Open a connection to the db
	 * 
	 */
	public SQLConnection() 
	{
		try 
		{
			Class.forName("com.mysql.jdbc.Driver").newInstance();
		} catch (Exception ex) {/* handle the error*/}
    
		try 
		{
			connection = DriverManager.getConnection("jdbc:mysql://localhost/roberg",username,password);
		} catch (SQLException ex) 
 	    	{/* handle any errors*/
			System.out.println("SQLException: " + ex.getMessage());
			System.out.println("SQLState: " + ex.getSQLState());
			System.out.println("VendorError: " + ex.getErrorCode());	
        }
	}

	/**
	 * @return the Connection
	 */
	public Connection getConnection() {
		return connection;
	}

	/**
	 * @return the password
	 */
	public static String getPassword() {
		return password;
	}

	/**
	 * @param password the password to set
	 */
	public static void setPassword(String password) 
	{
		SQLConnection.password = password;
	}

	/**
	 * @return the username
	 */
	public static String getUsername() 
	{
		return username;
	}

	/**
	 * @param username the username to set
	 */
	public static void setUsername(String username) 
	{
		SQLConnection.username = username;
	}
	
}